import logging
import redis


class Config(object):
    SECRET_KEY = "QWERTYUIOP"
    SQLALCHEMY_DATABASE_URI = "mysql://root:mysql@127.0.0.1:3306/information01"
    SQLALCHEMY_TRACK_MODIFICATIONS = False
    REDIS_HOST = "127.0.0.1"
    REDIS_PORT = 6379
    # 指定session的存储位置
    SESSION_TYPE = "redis"
    # 设置签名加密
    SESSION_USE_SIGNER = True
    # 设置session过期时间
    PERMANENT_SESSION_LIFETIME = 86400 * 2
    # 使用redis
    SESSION_REDIS = redis.StrictRedis(host=REDIS_HOST, port=REDIS_PORT)


class DevelopmentConfig(Config):
    """开发环境下的配置"""
    # 开启调试模式
    DEBUG = True
    LOG_DEVEL = logging.DEBUG


class ProductionConfig(Config):
    """生产环境下的配置"""
    LOG_DEVEL = logging.ERROR


class TestingCondig(Config):
    """测试环境下的配置"""
    TESTING = True
    LOG_DEVEL = logging.DEBUG


config = {
    "development": DevelopmentConfig,
    "production": ProductionConfig,
    "testing": TestingCondig
}